package com.leessy.r229.config

import android.util.Log
import com.leessy.r229.App
import com.tencent.mmkv.MMKV

/**
 * Global configuration
 *
 * manage by mmkv
 */
object Config {
    //default proxy configuration storage tool
    private val mmkv: MMKV by lazy {
        val initialize = MMKV.initialize(App.app)
        Log.d("TAG", "mmkv: $initialize")
//        MMKV.initialize(Constants.rootPath_Config)
        MMKV.defaultMMKV()!!
    }
    var taskId by mmkv.long("taskId", 0)
    var heatbeatInterval by mmkv.int("heatbeatInterval", 60)//心跳间隔

    var otaTaskId by mmkv.long("otaTaskId", 0L) //Config.otaTaskId
    var otaStatus by mmkv.boolean("otaStatus", false) //Config.otaTaskId
    var otaLastVer by mmkv.string("otaLastVer", "") //Config.otaTaskId

    var ipAddress by mmkv.string("ipAddress", "") //ipAddress
    var DEV_IMEI by mmkv.string("DEV_IMEI", "") //设备4G IMEI
    var DEV_IMSI by mmkv.string("DEV_IMSI", "") //设备4G IMSI
    var DEV_ICCID by mmkv.string("DEV_ICCID", "") //设备4G card sri
    var DEV_isSimCardReady = false //设备4G card isready
    var signalIntensityFor4G = 0//信号强度 4G (0-4)
    var signalIntensityForWIFI = 0//信号强度 WIFI (0-4)

    var hideapp by mmkv.string("hideapp", "")


    var autoRestartAt by mmkv.string("autoRestartAt", "")
    var deviceName by mmkv.string("deviceName", "HPT")
    var installationCtrl by mmkv.boolean("installationCtrl", false)
    var installationList by mmkv.string("installationList", "")
    var appEnableCtrl by mmkv.boolean("appEnableCtrl", false)
    var appEnableList by mmkv.string("appEnableList", "")
    var deviceExpire by mmkv.boolean("deviceExpire", false)
    var deviceExpireMsg by mmkv.string("deviceExpireMsg", "")
    var deviceLockMsg by mmkv.string("deviceLockMsg", "")
    var deviceLock by mmkv.boolean("deviceLock", false)
    var deviceAutoLockDate by mmkv.string("deviceAutoLockDate", "")
    var deviceExpireDay by mmkv.int("deviceExpireDay", 0) //

    var systemlog by mmkv.boolean("systemlog", false)

    var checkEncipher by mmkv.string("checkEncipher", "")
    var autoRunApp by mmkv.string("autoRunApp", "")

    var rebootTimes by mmkv.long("rebootTimes", 0)//最后重启时间， 1小时不重启设备


    var otaDisable by mmkv.boolean("otaDisable", false)  /*本地ota是否禁用*/
    var isDeleteDB by mmkv.boolean("isDeleteDB", false)  /*判断是否需要删除数据库*/
    var isOffline = false//是否在离线模式
    var isServerConnected = false//与服务器连接状态,定时心跳
    var networdStatus = 0//网络状态:  0没有网络  1 移动网络 2 WiFi网络 3 以太网
    fun isNetwork() = networdStatus > 0

    var password by mmkv.string("password", "12345678")  /*设备密码*/
    var identifyCallBack by mmkv.string("password", "") /*识别记录回调*/
    var deviceHeartBeat by mmkv.string("deviceHeartBeat", "") /*设备心跳回调*/
    var imgRegCallBack by mmkv.string("imgRegCallBack", "") /*自动拍照图片回调*/

    var cameraEC by mmkv.int("cameraEC", 0)/*曝光补偿-3 ~ 3*/


    /////////服务器参数相关///////

    var isEncrypt by mmkv.boolean("isEncrypt", false)/*服务请求加密*/
    var updateServerPath by mmkv.string(
        "updateServerPath",
        "http://device.hh-face.com:8188"
    )/*更新服务URL*/

    var findCardCheck by mmkv.boolean("findCardCheck", false) /*findCardCheck*/
    var sleepCamera by mmkv.boolean("sleepCamera", true) /*相机休眠*/
    var autoReboot by mmkv.boolean("autoReboot", true) /*autoReboot*/
    var autoRebootTime by mmkv.int("autoRebootTime", 2) /*autoRebootTime 2点*/
    var autoRebootLastDay by mmkv.string("autoRebootLastDay", "") /*最后启动时间记录*/

    var disableQr by mmkv.boolean("disableQr", false) /*qrInit 不使用扫码头时完全关闭初始化*/
    var ftpEnabled by mmkv.boolean("ftpEnabled", true)
    var balanceEnquiry by mmkv.boolean("balanceEnquiry", true)//0元输入人脸是否查询余额
    var disableQueryBalance by mmkv.boolean("disableQueryBalance", false)/*禁用余额查询，0元也走消费逻辑*/

    var adbw by mmkv.boolean("adbw", false)/*adbw*/

    var isLittleEndian by mmkv.boolean("IsLittleEndian", true)/*读卡高低位切换*/

    var livingLevel by mmkv.int("livingLevel", 2)/*活体等级： 1关闭， 2红外有人脸即可 3正常双目活体*/

    var cameraNum by mmkv.int("cameraNum", 2)/*记录设备是两个相机版本还是3个，只能加不能减*/

    var ttsName by mmkv.boolean("ttsName", false)//消费播报姓名
    var ttsCustom by mmkv.string("ttsCustom", "")//ttsCustom

    var topupMode by mmkv.boolean("topupMode", false)//充值模式
    var chargingShutdown by mmkv.boolean("chargingShutdown", true)//断开充电提示关机

    /**  0：定额消费  1: 定额消费（可变更）  2、自由消费  3. 菜品消费  4. 菜品消费（可校正） 5.订餐模式  6.就餐模式*/
    var consumptionType by mmkv.int("consumptionType", 2)
    var fixAmount by mmkv.string("fixAmount", "1.00")/*默认定额消费金额*/

    var printer_number by mmkv.int("printer_number", 1)/*默认打印单数*/
    var guestScreenShowMoney by mmkv.boolean("guestScreenShowMoney", true)/*客户屏显示消费金额*/


    fun getKeys(): Array<out String>? {
        return mmkv.allKeys()
    }

    /*clear configuration*/
    fun clear() {
        mmkv.clearAll()
    }

    fun sync() {
        mmkv.sync()
    }
}